package com.acme.bankapp.service.bank;
import com.acme.bankapp.domain.bank.*;

public class BankService {
	static final String MES_NULL_BANK_VARIABLE = "Object reference do not set to an instance of Bank object";
	static final String MES_NULL_CLIENT_VARIABLE = "Object reference do not set to an instance of Client object";

	public static void addClient(Bank bank, Client client) throws IllegalArgumentException {
		if (bank == null)
			throw new IllegalArgumentException(MES_NULL_BANK_VARIABLE);
		if (client == null)
			throw new IllegalArgumentException(MES_NULL_CLIENT_VARIABLE);
		
		bank.addClient(client);		
	}
	
	public static void printMaximumAmountToWithdraw(Bank bank) throws IllegalArgumentException {
		if (bank == null)
			throw new IllegalArgumentException(MES_NULL_BANK_VARIABLE);
		
		System.out.println("Bank maximum amount to withdraw:");
		for (Client client : bank.getClients()) {
			System.out.print(String.format("Client <%s>: ", client.getClientSalutation()));
			for (Account account : client.getAccounts()) {
				System.out.println(String.format("Max amount for account: %f", account.maximumAmountToWithdraw()));
			}
		}
		
	}
}
